package com.qf.fmall2202.index.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.fmall2202.exception.QfException;
import com.qf.fmall2202.index.entity.IndexImg;
import com.qf.fmall2202.index.dao.IndexImgDao;
import com.qf.fmall2202.index.service.IndexImgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.fmall2202.vo.ResultVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 轮播图  服务实现类
 * </p>
 *
 * @author 徐英海
 * @since 2022-11-04
 */
@Service
public class IndexImgServiceImpl extends ServiceImpl<IndexImgDao, IndexImg> implements IndexImgService {
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public ResultVo queryIndexImg() {
        List<IndexImg> indexImgList = this.list(new LambdaQueryWrapper<IndexImg>().eq(IndexImg::getStatus, 1));
        if (indexImgList.size() < 1) {
            throw new QfException("查询失败，无数据");
        }
        return ResultVo.ok("查询成功", indexImgList);
    }
}
